Expand description
Filesystem fixtures and assertions for testing.
assert_fs
aims to simplify
- Setting up files for your tests to consume
- Asserting on files produced by your tests
§Overview
Setting up a fixture
TempDir
orNamedTempFile
for a sandbox to test in.touch
aChildPath
orNamedTempFile
write_binary
aChildPath
orNamedTempFile
write_str
aChildPath
orNamedTempFile
write_file
aChildPath
orNamedTempFile
copy_from
a pristine folder to aChildPath
orTempDir
symlink_to_file
aChildPath
orNamedTempFile
symlink_to_dir
aChildPath
orTempDir
Validating
assert
aChildPath
,TempDir
, orNamedTempFile
§Example
Here is a trivial example:
use assert_fs::prelude::*;
use predicates::prelude::*;
let temp = assert_fs::TempDir::new().unwrap();
let input_file = temp.child("foo.txt");
input_file.touch().unwrap();
// ... do something with input_file ...
input_file.assert("");
temp.child("bar.txt").assert(predicate::path::missing());
temp.close().unwrap();
Modules§
- Filesystem assertions.
- Initialize the filesystem to use as test fixtures.
- Extension traits that are useful to have available.
Structs§
- A potential file in the filesystem that is automatically deleted when it goes out of scope.
- A directory in the filesystem that is automatically deleted when it goes out of scope.